const router = require('koa-router')();
const controller = require('../controller/c-user')

router.prefix('/user')

/**
 * @swagger
 * definition:
 *   loginParams: 
 *      properties:
 *          name:
 *              type: string
 *          password:
 *              type: string
 *   queryParams: 
 *      properties:
 *          name:
 *              type: string
 *   deletParams: 
 *      properties:
 *          userId:
 *              type: string
 *   updateParams: 
 *      properties:
 *          userId:
 *              type: string
 *          name:
 *              type: string
 *          password:
 *              type: string
 *          repeatpass:
 *              type: string
 *          avator:
 *              type: string
 *          phone:
 *              type: string
 *          email:
 *              type: string
 */

/**
 * @swagger
 * /user:
 *   get:
 *     summary: 用户信息列表接口
 *     description: 获取用户信息列表的应用
 *     tags:
 *       - 管理用户信息
 *     produces:
 *       - application/json
 *     responses:
 *       200:
 *         description: 成功获取
 */
// 用户信息列表
router.get('/', controller.getPosts)

/**
 * @swagger
 * /user/list:
 *   post:
 *     summary: 查询用户接口
 *     description: 查询用户信息列表的应用
 *     tags:
 *       - 管理用户信息
 *     produces:
 *       - application/json
 *     parameters:
 *       - name: params 
 *         in: body
 *         required: true
 *         description: 用户名称
 *         schema:
 *           $ref: '#/definitions/queryParams'
 *     responses:
 *       200:
 *         description: 成功获取
 */
// 查询用户
router.post('/list', controller.getPosts)

/**
 * @swagger
 * /user/delet:
 *   delete:
 *     summary: 删除指定id用户接口
 *     description: 删除指定id用户的应用
 *     tags:
 *       - 管理用户信息
 *     produces:
 *       - application/json
 *     parameters:
 *       - name: params
 *         in: body
 *         required: true
 *         schema:
 *           $ref: '#/definitions/deletParams'
 *     responses:
 *       200:
 *         description: 成功删除
 */
// 删指定id用户
router.delete('/delet', controller.postDeleteUser)

/**
 * @swagger
 * /user/update:
 *   put:
 *     summary: 更新相应id用户信息接口
 *     description: 更新指定id用户的应用
 *     tags:
 *       - 管理用户信息
 *     produces:
 *       - application/json
 *     parameters:
 *       - name: params
 *         in: body
 *         required: true
 *         description: 应用名称
 *         schema:
 *           $ref: '#/definitions/updateParams'
 *     responses:
 *       200:
 *         description: 更新获取
 */
// 更新用户信息
router.put('/update', controller.upDateUserInfo)

module.exports = router